<?php

/*****
* File :    .php
* module :  
* Created:  
* Update:   
* Function: 
* Author:   Eugene Heriniaina
* Email:    hery@serasera.org
* Comment:  
*******/




switch($task) {
	default:
		if($username) {
			necro_view( $option, $username );
		} else {
			necro_list( $option );
		}
		break;
}


function necro_view( $option, $username ) {
	global $database;
	
	$query = "SELECT p.*, n.* FROM #__congregation_profile AS p "
	. "\nLEFT JOIN #__users AS u ON p.username=u.username "
	. "\nLEFT JOIN #__congregation_necro  AS n  ON p.username=n.username "
	. "\nWHERE p.username='$username' ";

	$database->setQuery( $query );
	$rows = $database->loadObjectList();
	$row = $rows[0];

	HTML_necro::necro_view( $row, $option );
}


class HTML_necro {

	function necro_view( &$row, $option ) {
		global $params, $Itemid, $mosConfig_live_site;
			?>
			<div class="componentheading<?php echo $params->get( 'pageclass_sfx' ); ?>">
			<?php echo $row->lname . " " . $row->fname ; ?>
			</div>
<center><?php
	if($row->picfile) {
	echo  "
	  <a href=\"javascript:PopupAlbum('". $row->fname . " " . $row->lname. "', '" . $mosConfig_live_site . "/media/profiles/".$row->picfile. "')\" ><img src='" . $mosConfig_live_site . "/media/profiles/s". $row->picfile . "' border='0' width='100'></a><br />
	";
	}
	 
?></center>
			<div style="background-color:#F5F5F5; border:1px solid #E8E8E8; margin-bottom:10px; padding:5px;"><table>
			<?php 
				echo "<tr><td valign='top'>" . _Profile_Birth . ": </td><td valign='top'>" . preg_replace('/^(.{4})-(.{2})-(.{2})$/','$3-$2-$1', $row->bdate) . "</td></tr>";
				echo "<tr><td valign='top'>" . _Profile_Prof . ": </td><td valign='top'>" . preg_replace('/^(.{4})-(.{2})-(.{2})$/','$3-$2-$1', $row->vdate) . "</td></tr>";
				echo "<tr><td valign='top'>" . _Profile_Ordination . ": </td><td valign='top'>" . preg_replace('/^(.{4})-(.{2})-(.{2})$/','$3-$2-$1', $row->odate) . "</td></tr>";
				echo "<tr><td valign='top'>" . _Profile_Death . ": </td><td valign='top'>" . preg_replace('/^(.{4})-(.{2})-(.{2})$/','$3-$2-$1', $row->ddate) . "</td></tr>";
			?></table>
			</div>
			<?php 

		echo ampReplace( $row->texte );
	}

}

class congregationNecro extends mosDBTable {
	var $id = null;
	var $username = null;
	var $author = null;
	var $date = null;
	var $texte = null;

	function congregationNecro( &$db ) {
		$this->mosDBTable( '#__congregation_necro', 'id', $db );
	}
}

?>